package gttp.nspa.shared.om;

import java.io.InputStreamReader;
import java.util.List;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.annotations.SerializedName;
import com.google.gson.reflect.TypeToken;

public class Massa extends Product {

    @SerializedName("u")
    private int duration;

    public int getDuration() {
        return duration;
    }

    public String toString() {
        ToStringBuilder tsb = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE);
        tsb.appendSuper(super.toString());
        tsb.append("u", duration);
        return tsb.toString();
    }

    public static void main(String[] args) throws Exception {
        List<Massa> ps;
        Gson gson = new GsonBuilder().setPrettyPrinting().create();
        InputStreamReader reader = new InputStreamReader(Massa.class.getResourceAsStream("/data/massas.json"));
        try {
            ps = gson.fromJson(reader, new TypeToken<List<Massa>>() {}.getType());
            System.out.println(ps.toString());
        } finally {
            reader.close();
        }
    }
}
